package com.example.XqmZsb.interceptor;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class SignatureInterceptor implements HandlerInterceptor {
    @Value("${apiKey}")
    private String apiKey;

    @Value("${apiSecret}")
    private String apiSecret;


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String sign = request.getParameter("sign");
        String timestamp = request.getParameter("timestamp");
        return true;
        /*if (StringUtils.isNotBlank(sign) && StringUtils.isNotBlank(timestamp)){
            String signature = SignatureUtil.getSignature(timestamp, apiKey, apiSecret);
            if (StringUtils.isNotBlank(signature) && signature.equals(sign) ){

                return true;
            }else{
                request.getRequestDispatcher("/ban").forward(request,response);
                return  false;
            }
        }else{
            request.getRequestDispatcher("/ban").forward(request,response);
            return false;
        }*/
    }
}
